package cn.ljy.mes.model;

import cn.ljy.common.model.BaseModel;
import cn.ljy.common.model.validate.AddWorkValidation;
import cn.ljy.common.model.validate.UpdateWorkValidation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 商城汽车订单表实体类
 */
@ApiModel(value = "商城汽车订单")
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false, of = {"id"})
public class ShopCarOrder extends BaseModel {

    @ApiModelProperty(value = "订单ID", example = "01f15383-7cb4-11f0-92a2-0250f2033332")
    @NotNull(groups = UpdateWorkValidation.class, message = "订单ID不能为空")
    private String id;

    @ApiModelProperty(value = "客户", required = true)
    @NotNull(groups = AddWorkValidation.class, message = "客户不能为空")
    private ShopCustomer customer;

    @ApiModelProperty(value = "商品", required = true)
    @NotNull(groups = AddWorkValidation.class, message = "商品不能为空")
    private ShopCarProduct carProduct;

    @ApiModelProperty(value = "汽车配置对象（关联查询），不用传值，由业务层根据商品对象直接处理")
    private MesCarModelConfig carModelConfig;

    @ApiModelProperty(value = "原价，不用传值也不允许修改", required = true, example = "44800.00")
    private BigDecimal originalPrice;

    @ApiModelProperty(value = "促销价,添加时不用传值，未付款前可以传值修改", required = true, example = "42800.00")
    @DecimalMin(value = "0.01", message = "促销价必须大于0")
    @Digits(integer = 10, fraction = 2, message = "促销价最多支持10位整数和2位小数")
    private BigDecimal promotionPrice;

    @ApiModelProperty(value = "支付时间，不用传值", example = "2025-08-18 12:28:26")
    private Date paymentTime;

    @ApiModelProperty(value = "订单状态，不用传值", required = true,
            allowableValues = "pending,paid,confirmed,producing,produced,shipped,completed,cancelled",
            example = "pending")
    private String orderStatus;

    @ApiModelProperty(value = "客户名称,添加时不用传值，未邮寄前可以传值修改", required = true, example = "李四")
    @Length(min = 2, max = 20, message = "客户名称长度必须在{min}-{max}之间")
    private String deliveryName;

    @ApiModelProperty(value = "客户电话,添加时不用传值，未邮寄前可以传值修改", required = true, example = "13422222222")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String deliveryTel;

    @ApiModelProperty(value = "客户邮编,添加时不用传值，未邮寄前可以传值修改", required = true, example = "134321")
    @Pattern(regexp = "^[0-9]{6}$", message = "邮编必须是6位数字")
    private String deliveryZip;

    @ApiModelProperty(value = "配送地址,添加时不用传值，未邮寄前可以传值修改", required = true, example = "北京大学")
    @Length(max = 100, message = "地址长度不能超过{max}个字符")
    private String deliveryAddress;

    @ApiModelProperty(value = "订单备注,添加时不用传值，未邮寄前可以传值修改", example = "急需")
    @Length(max = 255, message = "备注长度不能超过{max}个字符")
    private String remark;

    @ApiModelProperty(value = "订单确认时间", example = "2025-08-19 12:29:32")
    private Date confirmedTime;

    @ApiModelProperty(value = "汽车发送时间", example = "2025-08-19 12:29:32")
    private Date shippedTime;

    @ApiModelProperty(value = "订单完成时间", example = "2025-08-19 12:29:32")
    private Date completedTime;

    @ApiModelProperty(value = "订单取消类型，不需要传值，由系统根据业务判断", notes = "共有三个值：'customer_cancelled','production_cancelled','merchant_cancelled'")
    private String cancelledType;

    @ApiModelProperty(value = "订单取消时间", example = "2025-08-19 12:29:32")
    private Date cancelledTime;

    @ApiModelProperty(value = "创建时间", example = "2025-08-19 12:29:32")
    private Date createTime;

    @ApiModelProperty(value = "更新时间", example = "2025-08-19 12:30:00")
    private Date updateTime;

    // 非数据库字段

    public ShopCarOrder(String id) {
        this.id = id;
    }
}